package DSENS;

/**
 *
 * @author teeteto
 */
import java.util.ArrayList;

/*
class GlobalInfo{
    public static String CODE = new String("Ex_00001");
    public static int NoNodes = 250;
    public static int WirelessRange = 100;
    public static long SEED = 234;
    public static int round = 5000;
    public static TimeLine TIMELINE = new TimeLine(100000);
}
*/

public class NetworkSimulator {

   public static void main(String args[]) {
    try{
        Log l = new Log();
        Node.NodeState st = null;
        ArrayList<Node> net = new ArrayList<Node>(GlobalInfo.NoNodes);
        
        //Network specific pararmeters
        int areaX=1000;
        int areaY=1000;
        
        WSNNetworkManager wm = new WSNNetworkManager(net,areaX,areaY);
        wm.initNetworks();
       // for(int i=0;i<net.size();i++) l.printNode(net.get(i));
        wm.powerConsumption(1);
        //wm.buildMET2(0);
        //wm.initNetworks();
        //wm.printWSN();
        //wm.getInfo();
        //Nodes state
       // for(int i=0;i<net.size();i++) l.printNode(net.get(i));
            l.printNode(net.get(0));

        //manage event
        Message msg = new Message(0);
        Event ev = new Event(0,0,"start",0,msg); //genera evento da 0 a 0
        GlobalInfo.TIMELINE.addEvent(0, ev); //inserisci in slot 0
/*
        int index_tmp=0;
        for(int i=0; i<10;i++){
            index_tmp=(int)(Math.random()*GlobalInfo.NoNodes);
            ev = new Event(0,index_tmp,"CH",0,msg); //genera evento da 0 a 0
            GlobalInfo.TIMELINE.addEvent(500, ev); //inserisci in slot 500
        }

        for(int i=0; i<GlobalInfo.NoNodes;i++){
            ev = new Event(0,i,"Check",0,msg); //genera evento da 0 a 0
            GlobalInfo.TIMELINE.addEvent(2000, ev); //inserisci in slot 500
        }*/
        //Create Event Manager
        EventManager em = new EventManager();

        //run simulation
        System.out.println("Run simulation...");
        while(em.execEvent(net)!=false){}
        //CreateFileDot.printDot(net);
         wm.printWSN();
         wm.getInfo();
         wm.powerConsumption(2);
         //for(int i=0;i<net.size();i++) l.printNode(net.get(i));
    }catch(LogException le){
        le.printStackTrace();
    }
   }   
}
